using System;
using System.Collections.Generic;
using System.Text;

namespace Axe
{
    public static partial class Utility
    {
        #region public static string ToString(TimeSpan span)
        public static string ToString(TimeSpan span)
        {
            if (span == TimeSpan.MaxValue)
                return Time_Resources.TimeSpan_MaxValue;
            if (span == TimeSpan.MinValue)
                throw new ArgumentException();

            StringBuilder sb = new StringBuilder();

            if (span.Days > 0)
            {
                sb.AppendFormat("{0} {1}", span.Days, Time_Resources.TimeSpan_DayName);
            }

            if (span.Hours > 0)
            {
                if (sb.Length > 0)
                    sb.Append(" ");
                sb.AppendFormat("{0} {1}", span.Hours, Time_Resources.TimeSpan_HrsName);
            }

            if (span.Minutes > 0)
            {
                if (sb.Length > 0)
                    sb.Append(" ");
                sb.AppendFormat("{0} {1}", span.Minutes, Time_Resources.TimeSpan_MinName);
            }

            if (span.Seconds > 0)
            {
                if (sb.Length > 0)
                    sb.Append(" ");
                sb.AppendFormat("{0} {1}", span.Seconds, Time_Resources.TimeSpan_SecName);
            }

            return sb.ToString();
        } 
        #endregion

        #region public static string GetMonthName(int monthNum, bool abbreviate)
        public static string GetMonthName(int monthNum, bool abbreviate)
        {
            if (monthNum < 1 || monthNum > 12)
                throw new ArgumentOutOfRangeException("monthNum");
            DateTime date = new DateTime(1, monthNum, 1);
            if (abbreviate)
                return date.ToString("MMM");
            else
                return date.ToString("MMMM");
        } 
        #endregion
    }
}
